package hero_info

import "go_server/game_server/protocol/pb"

func (h *Cache_hero_info_field_hero) ToPB_HeroCardData() *pb.HeroCardData {
	card := &pb.HeroCardData{
		Basic: &pb.HeroBasicData{
			Cfgid: h.CfgId,
			Serid: h.SerId,
			Level: h.LvId,
			Star:  h.StarId,
			Exp:   h.Exp,
			Fight: h.Fight,
		},
	}

	if h.Skills != nil {
		for _, sv := range h.Skills {
			card.Skills = append(card.Skills, &pb.HeroSkillData{
				Serid: sv.Serid,
				Cfgid: sv.CfgId,
				Level: sv.Lv,
			})
		}
	}

	if h.Cells != nil {
		for _, cv := range h.Cells {
			card.Cells = append(card.Cells, &pb.HeroCellData{
				Serid: cv.Serid,
				Cfgid: cv.CfgId,
				Level: cv.Lv,
			})
		}
	}

	return card
}
